package com.xiaofei.future;

public class FutureData implements Data {
	private boolean isReady;
	private RealData realData;
	@Override
	public synchronized Entity getResult() {
		while(!isReady){
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		return realData.getResult();
	}
	
	public synchronized void setResult(RealData realData){
		if(isReady){
			return;
		}
		this.realData=realData;
		isReady=true;
		notifyAll();
	}
}
